{% extends "base.html" %}
{% block title %}养殖追踪---查询养殖情况{% endblock %}
{% block sample_breeding %} active {% endblock %}
{% block content %}
    <!--页面大标题及描述-->
    <h1>养殖样本追踪</h1>
    <p class="describe">您可以在此查找所有的养殖类样本的信息并对其进行您需要的操作</p>
    <div class="separator"></div>

    <div class="content" style="margin:0 auto;width:1290px" >
        <div class="col-sm-6" style="margin-bottom">
            <span style="font-size:14px">显示：</span>
                <select id="select_num">
                    <option>15</option>
                    <option>30</option>
                    <option>50</option>
                </select>
            <span style="font-size:14px">条数据</span>
        </div>
        <div class="col-sm-6" style="float:right;width:34%;">
            <span id="select_status"style="font-size: 14px;float:left">样本状态
                <select style="font-size:12px">
                    <option>全部</option>
                    <option>待分析</option>
                    <option>已完成</option>
                    <option>分析中</option>
                    <option>分析超时</option>
                    <option>分析失败</option>
                    <option>取消分析</option>
                </select>
            </span>                              
            <input type="text" class="form-control nav-input-search" id="breed_search_text"
            style="width: 250px;margin-left:10px;font-size:12px;height:22px;float:left" placeholder="文件名、HASH、时间(年-月-日)">
            <button class="fa fa-search fa-lg btn btn-default" id="breed_search_btn"></button>
        </div>

        <table class="table table-striped table-hover"style="width:100%">
            <thead>
                <th style="width:325px">HASH<i id="icon_hash"style="margin-left:260px;"><img src="/static/css/image/sort_both.png"></i></th>
                <th style="width:75px">养殖状态<i id="icon_status"><img src="/static/css/image/sort_both.png"></i></th>
                <th style="width:131px">开始养殖时间<i id="icon_start"style="margin-left:31px"><img src="/static/css/image/sort_both.png"></i></th>
                <th style="width:131px">投放时间<i id="icon_create" style="margin-left:56px"><img src="/static/css/image/sort_both.png"></i></th>
                <th style="width:110px">养殖时间<i id="icon_breed_time" style="margin-left:35px;"><img src="/static/css/image/sort_both.png"></i></th>
                <th style="width:96px">原始文件名<i id="icon_name" style="margin-left:8px"><img src="/static/css/image/sort_both.png"></i></th>
                <th style="width:75px">文件大小<i id="icon_size"><img src="/static/css/image/sort_both.png"></i></th>
                <th style="width:82px">文件类型<i id="icon_type" style="margin-left:7px"><img src="/static/css/image/sort_both.png"></i></th>
                <th style="width:75px">投放人员<i id="icon_user"><img src="/static/css/image/sort_both.png"></i></th>
                <th >操作</th>
                <th style="width:125px">下载</th>
            </thead>
            {%if result.count==0 %}
            <tr>
                <td colspan="11" style="text-align: center;height: 4em;line-height: 4em">
                    <span style="font-size: 14px;">暂时没有数据</span>
                </td>
            </tr>
            {% else %}
            {% for item in result.content %}
            <tr>
                <td>
                {% if item.status=="分析中" %}
                    <a href="http://10.128.127.249:5000/report/breed_run/{{item.hash}}">{{item.hash}}</a>
                {% elif item.status=="已完成" %}
                    <a href="http://10.128.127.249:5000/report/breed/{{item.hash}}">{{item.hash}}</a>
                {% else %}
                    {{item.hash}}
                {% endif %}
                </td>
                {% if item.status=='分析失败' or item.status=='分析超时'%}
                    <td id="status"><span class="label label-default"style="background-color: rgb(255, 58, 1);">{{ item.status }}</span></td>
                {% endif %}
                {% if item.status=='分析中'%}
                    <td id="status"><span class="label label-default label-info">{{ item.status }}</span></td>
                {% endif %}
                {% if item.status=='待分析'%}
                    <td id="status"><span class="label label-default bg-color-gray">{{ item.status }}</span></td>
                {% endif %}
                {% if item.status=='已完成'%}
                    <td id="status"><span class="label label-default label-success">{{ item.status }}</span></td>
                {% endif %}
                <td>{{item.date_start}}</td>
                <td>{{item.date_create}}</td>
                <td>{{item.breed_time}}</td>
                <td class="td-hash tooltip-test" data-toggle="tooltip" title="{{item.file_name}}">{{item.file_name}}</td>
                <td>{{item.file_size}}</td>
                <td class="td-hash tooltip-test" data-toggle="tooltip" title="{{item.file_type}}">{{item.file_type}}</td>
                <td class="td-hash tooltip-test" data-toggle="tooltip" title="{{item.username}}">{{item.username}}</td>
                <td> 
                    <input name = "{{item.task_id}}" style="display:none">
                {% if item.status == '分析中' or item.status=='待分析' %}                       
                    <a href="http://10.128.126.2:8000/command/?command=stop&task_id={{item.task_id}}" style="color:#31b0d5">终止养殖</a>
                {% endif %}
                </td>
                {% if item.status == '待分析' or item.status=='分析失败' or item.status=='分析超时'%}
                <td>
                    <select style="width:75px">
                        <option>样本</option>
                    </select>
                    <button class="btn btn-default fa fa-download"></button>
                </td>
                {% endif %}
                {% if item.status == '分析中'%}
                <td>
                    <select style="width:75px">
                        <option>样本</option>
                        <option>avml</option>
                        <option>pcap</option>
                        <option>历史记录</option>
                    </select>   
                    <button class="btn btn-default fa fa-download"></button>
                </td>
                {% endif %}

                {% if item.status == '已完成' or item.status =='取消分析'%}
                <td>
                    <select style="width:75px">
                        <option>样本</option>
                        <option>avml</option>
                        <option>pcap</option>
                        <option>dump</option>
                        <option>历史记录</option>
                    </select>
                    <button class="btn btn-default fa fa-download"></button>
                </td>
                {% endif %}
                <td style="display:none">{{item.task_id}}</td>
                <td style="display:none">{{item.hash}}</td>
            </tr>
            {% endfor %}
        {% endif %}
        </table>
        <div>
            <span id="str_page"></span>
            <ul class="page_the_show pagination" style="float:right;margin-bottom:50px;margin-top:-5px">
            </ul>
        </div>

        <ul class="page_the_hide pagination" style="float:right;margin-bottom:50px;margin-top:-5px;display:none">
            <li><a id = "pre" ><span>&laquo;</span></a></li>
            <li><a id = "first"><span>首页</span></a></li>
            {% if result.count%result.page_size==0 %}
                {% for num in range(1,(result.count//result.page_size)+ 1) %}

                    {% if result.status=='' and result.condition!=''%}
                        <li><a href="/breed_track/{{num}}/{{result.page_size}}/{{result.order}}/condition/{{result.condition}}"><span>{{num}}</span></a></li>
                    {% endif %}

                    {% if result.status!='' and result.condition==''%}
                        <li><a href="/breed_track/{{num}}/{{result.page_size}}/{{result.order}}/status/{{result.status}}"><span>{{num}}</span></a></li>
                    {% endif %}

                    {% if result.status!='' and result.condition!=''%}
                        <li><a href="/breed_track/{{num}}/{{result.page_size}}/{{result.status}}/{{result.condition}}/{{result.order}}"><span>{{num}}</span></a></li>
                    {% endif %}

                    {% if result.status=='' and result.condition==''%}
                        <li><a href="/breed_track/{{num}}/{{result.page_size}}/{{result.order}}"><span>{{num}}</span></a></li>
                    {% endif %}

                {% endfor %}
            
            {% else %}
                {% for num in range(1,(result.count//result.page_size)+ 2) %}

                    {% if result.status=='' and result.condition!=''%}
                        <li><a href="/breed_track/{{num}}/{{result.page_size}}/{{result.order}}/condition/{{result.condition}}"><span>{{num}}</span></a></li>
                    {% endif %}

                    {% if result.status!='' and result.condition==''%}
                        <li><a href="/breed_track/{{num}}/{{result.page_size}}/{{result.order}}/status/{{result.status}}"><span>{{num}}</span></a></li>
                    {% endif %}

                    {% if result.status!='' and result.condition!=''%}
                        <li><a href="/breed_track/{{num}}/{{result.page_size}}/{{result.status}}/{{result.condition}}/{{result.order}}"><span>{{num}}</span></a></li>
                    {% endif %}

                    {% if result.status=='' and result.condition==''%}
                        <li><a href="/breed_track/{{num}}/{{result.page_size}}/{{result.order}}"><span>{{num}}</span></a></li>
                    {% endif %}

                {% endfor %}
            {% endif %}
            <li><a id = "last"><span>尾页</span></a></li>
            <li><a><span>&raquo;</span></a></li>
        </ul>
    </div>
<!--<div id="Pagination" class="quotes"></div> -->
    <div id="page_num" style="display:none">
        {% if result.count%result.page_size==0 %}
            {{(result.count//result.page_size)}}
        {% else %}
            {{(result.count//result.page_size)+1}}
        {% endif %}
    </div>
    <div id="result_count" style="display:none">{{result.count}}</div>
    
    <button id="upload_history_button" data-toggle="modal" data-target="#myModal_history_result"style="display:none"></button>

    <div class="modal fade" id="myModal_history_result" tabindex="-1" role="dialog"
         aria-labelledby="myModalLabel_loading" aria-hidden="true">
            <div class="modal-dialog" style="width: 420px;margin-top:280px !important">
            <div class="modal-content">
                <div class="modal-head" style="border-bottom:1px solid #ddd">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="margin-right:15px">
                        &times;
                    </button>
                    <h2 style="font-size: 20px;margin-left: 20px;font-family: Microsoft Yahei;">历史记录</h2>
                </div>
                <div class="modal-body " style="height: 300px;width: 420px">
                    <span>注：下载的内容为每一次处理生成的avml文件。</span>
                    <ul id="result_history" style="height:220px;overflow:auto;margin-top:10px">
                        
                    </ul>

                </div>
            </div><!-- /.modal-content -->
        </div>
    </div>
{% endblock %}    
